const  path=require('path')
const  fs=require('fs')
const  url=require('url') //解析参数实现对象的形式
const  express=require("express")


const router=express.Router()

//这个也是路由1
router.get('/',(req,res)=>{
    // fs.readFile(path.resolve(__dirname,'./public/home.html'),(err,data)=>{
    //     if(err) throw new Error(err)
    //     res.send(data)
    // })
    res.send({name:'home',...req.aaa})
})

//路由二 
// router.get()


router.get('/list',(req,res)=>{
  console.log(req.aaa)

    res.send({name:'list',aaa:req.aaa})
})

router.get('/news/:id',(req,res)=>{
    //    req.params
        res.send({name:'news',...req.params})
    })

 router.get('/books',(req,res)=>{
       res.send({name:'books',...req.query})
 })   


 router.post('/post',(req,res)=>{

    console.log(req.body)
     res.send({name:'post',  ...req.body})
 })


module.exports  =router